---------------
-- PHAGE MAW --
---------------
local Locales = {
	["Phage Maw"] = {
		[1] = "Phage Maw",
		[2] = "Phagenschlund",
		[3] = "Phagegueule",
	},
	["Detonation Bomb"] = {
		[1] = "Detonation Bomb",
		[2] = "Sprengbombe",
		[3] = "Bombe à détonateur",
	},
	["Detonation Bombs"] = { --60612
		[1] = "Detonation Bombs",
		[2] = "Sprengbomben",
		[3] = "Bombes explosives",
	},
	["Crater"] = { --60442
		[1] = "Crater",
		[2] = "Krater",
		[3] = "Cratère",
	},
	["Air phase"] = {
		[1] = "Air phase",
		[2] = "Flugphase",
		[3] = "Envol",
	},
	["Bombs"] = {
		[1] = "Bombs",
		[2] = "Bomben",
		[3] = "Bombes",
	},
	["STACK ON CENTER!!!"] = {
		[1] = "STACK ON CENTER!!!",
		[2] = "In der Mitte sammeln!",
		[3] = "PACK AU CENTRE!!!",
	},
	["Bombs left - "] = {
		[1] = "Bombs left - ",
		[2] = "Bomben übrig - ",
		[3] = "Bombes restantes - ",
	},
}

local function GAPhageMaw(tUnits)
	local locBombsLeft = Raiderino.L["Bombs left - "]
	
	local currTime = GameLib.GetGameTime()
	for unitid, unitdata in pairs(tUnits) do
		local unitname = unitdata.unit:GetName()
		if unitname == Raiderino.L["Phage Maw"] then
			local castname = Raiderino:GetCast(unitid,unitdata.unit)
			if castname then
				if castname == Raiderino.L["Detonation Bombs"] then
					if Raiderino:FeatureCheck("Phage Maw","Detonation Bombs") then
						local msg = {text = "Detonation Bombs", maxtime = 29, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Crater"] then
					if Raiderino:FeatureCheck("Phage Maw","Air phase") then
						local msg = {text = "Air phase", maxtime = 112, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
					if Raiderino:FeatureCheck("Phage Maw","Bombs") then
						local msg = {text = "Bombs", maxtime = 112, icon = nil, destroyAtEnd = true}
						Raiderino.notifications:AddTimer(msg)
						Raiderino.notifications.content["Bombs"].Frame:FindChild("Text"):SetText(locBombsLeft .. 0)
					end
				else
					Raiderino:UntimedCastAdd(unitname,castname)
				end
			end
		end
	end
	
	if Raiderino:FeatureCheck("Phage Maw","Air phase") then
		if Raiderino.timers.content["Air phase"] and not Raiderino.timers.content["Air phase"].notified then
			if Raiderino.timers.content["Air phase"].EndTime - currTime < 10 and not Raiderino.notifications.content["STACK ON CENTER!!!"] then
				Sound.PlayFile(Raiderino.notifications.contentSoundNew)
				local msg = {text = "STACK ON CENTER!!!", maxtime = 10, icon = nil, destroyAtEnd = true}
				Raiderino.notifications:AddTimer(msg)
				Raiderino.timers.content["Air phase"].notified = true
			end
		end
	end
	
	if Raiderino:FeatureCheck("Phage Maw","Bombs") then
		local bombcount = 0
		for unitid, unitbar in pairs(Raiderino.unitframe.content) do
			if unitbar.text == Raiderino.L["Detonation Bomb"] then
				bombcount = bombcount + 1
			end
		end
		if Raiderino.notifications.content["Bombs"] then
			Raiderino.notifications.content["Bombs"].Frame:FindChild("Text"):SetText(locBombsLeft .. bombcount)
		end
	end
end

local function PhasePhageMaw(phase)

end

local function StartPhageMaw()

end
----------------
-- /PHAGE MAW --
----------------

local encounteroptions = {
	enabled = true,
	position = 7,
	zone = "Genetic Archives - Act 2",
	fBossFunction = GAPhageMaw,
	fPhaseFunction = nil,
	fOnStartCombat = nil,
	features = {
		["Detonation Bombs"] = {
			displayname = "Detonation Bombs",
			enabled = true
		},
		["Air phase"] = {
			displayname = "Air phase",
			enabled = true
		},
		["Bombs"] = {
			displayname = "Bombs",
			enabled = true
		},
	},
}

if _G["RaiderinoLibs"] == nil then
	_G["RaiderinoLibs"] = { }
end
if _G["RaiderinoLibs"]["Encounters"] == nil then
	_G["RaiderinoLibs"]["Encounters"] = { }
end

_G["RaiderinoLibs"]["Encounters"]["Phage Maw"] = encounteroptions

if _G["RaiderinoLibs"]["Locales"] == nil then
	_G["RaiderinoLibs"]["Locales"] = { }
end
for locale, localedata in pairs(Locales) do
	if not RaiderinoLibs.Locales[locale] then
		RaiderinoLibs.Locales[locale] = {}
		for i,localestring in pairs(localedata) do
			RaiderinoLibs.Locales[locale][i] = localestring
		end
	end
end